import { defaultLayout } from '@/settings.js'
import { useDark } from '@vueuse/core'
import { defineStore } from 'pinia'

export const useAppStore = defineStore('app', {
  state: () => ({
    // 布局模式
    layout: defaultLayout,
    // 主题: 白色、暗黑
    isDark: useDark(),
  }),
  actions: {
    // 设置布局模式
    setLayout(v) {
      this.layout = v
    },
    // 切换主题
    toggleDark() {
      this.isDark = !this.isDark
    },
  },
  persist: {
    paths: ['layout'],
    storage: sessionStorage,
  },
})
